#     Xepec.ru - социальная сеть
#     Copyright (C) 2008  Fedorchenko Alexander <admin@xepec.ru>
#
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as
#     published by the Free Software Foundation, either version 3 of the
#     License, or (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
#
#     You should have received a copy of the GNU Affero General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#     Autor: Fedorchenko Alexander
#     Mail: <admin@xepec.ru>
#     Date: 06/02/2010
#

#require "config.pl";
require "../core.pl";

$auth_id = do_check();

&get_query();
$cat=$queryString{ "cat" };
if($auth_id != 1) {print "Location: $SITE_ADDR\n\n"; exit();};

###############################################################################################################################
#----------------------------------------------Вывод на экран информации------------------------------------------------------#
###############################################################################################################################
print "Content-Type: text/html; charset=utf-8", "\n\n";

print qq{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
	<title>$SITE_NAME :: Главнейшая страница</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />

	<script src="/js/md5.js" type="text/javascript"></script>

	<link rel="stylesheet" type="text/css" href="admin_style.css" media="screen" title="style (screen)" />

	<script type="text/javascript" src="/js/core.js"></script>
	



</head>
<body>
<div id="preload"></div>
<div id="header">};
print "<h1>".$uname['nic']."  <span>\@$SITE_NAME2</span></h1>";
print qq{<big>$SITE_NAME</big> </div>};
  
print $text;


print qq{

<div id="main">
  <div id="container">
    <div id="subnav">
      <ul>
        <li><a href="?cat=generic">Общие</a></li>
        <li class="child"><a href="?cat=pepyaka">Рейтинг</a></li>
        <li class="child"><a href="?cat=users">Пользователи</a></li>
        <li><a href="?cat=bugzilla">Багзилла</a></li>
<!--     <li><a href="#">Subnav 2</a></li>
          <li class="child"><a href="#">Child 1</a></li>
          <li class="child"><a href="#">Child 2</a></li>
        <li /><a href="#" />Subnav 3</a></li>
          <li class="child"><a href="#">Child 3</a></li>
          <li class="child"><a href="#">Child 4</a></li>-->
      </ul>
    </div>

    <div id="content">
     <!-- контент -->

};

use Switch;
switch ($cat)
{
	case "generic"
	{	
		# 1. Чтение конфига
		
	}
	case "pepyaka"
	{	
		# 1. Наити пользователя по id перещитать ему пепяку
		# 2. Перещитать всем
		
	}
	case "users"
	{	
		print qq{<table border="1" width="100%">
			<thead><th>ID</th><th>Nic</th><th>ФИО</th><th>Пол</th><th>Инфо</th><th>Возраст</th><th>Рейтинг</th></thead>
			};
		
			$ath = $dbcnx->prepare(qq{SELECT *,(YEAR(CURRENT_DATE) - YEAR(bday)) - (RIGHT(CURRENT_DATE,5)<RIGHT(bday,14)) AS age FROM username});
			$ath->execute() or die("hi (error #3)");
			#@sss = $ath->fetchrow_array();

			while(my @sss = $ath->fetchrow_array() )
			{
				if (@sss['5'] == 1){$sex = '<span style="color: blue">♂</span>'}elsif (@sss['5'] == 8){$sex = '<span style="color: red">♀</span>'}else{$sex = 'хз'}
				print qq{\t\t\t\t<tr><td>@sss['0']</td><td><a href="/username/index.pl?uname=@sss['0']">@sss['3']</a></td><td>@sss['1']</td><td>$sex</td><td>status=""</td><td>@sss['17']</td><td>@sss['11']</td></tr>\n};
			}
		print qq{</table>};
	}
	case "bugzilla"
	{	
		print qq{<table border="1" width="100%">
			<thead><th>#</th><th>Место проблемы</th><th>Автор</th><th>Комментарий</th><th>Время</th><th>Отметка при исправление</th><th>Дата исправления</th><thead>
			};
		
			$ath = $dbcnx->prepare(qq{SELECT * FROM bugzilla});
			$ath->execute() or die("hi (error #3)");
			#@sss = $ath->fetchrow_array();

			while(my @sss = $ath->fetchrow_array() )
			{
				my $type = &convert_bugzilla_type($sss[1]);
				if(!$sss['6']) {$sss['6'] = "Еще не исправлено";$sss['7'] = "&#160;";}
				print qq{\t\t\t\t
					<tr>
						<td><a href="?cat=bugzilla-check&id=$sss['0']">$sss['0']</td>
						<td>$type</td>
						<td><a href="mailto: $sss['3']">$sss['2']</a></td>
						<td>$sss['4']</td>
						<td>$sss['5']</td>
						<td>@sss['6']</td>
						<td>@sss['7']</td>
					</tr>\n};
			}
		print qq{</table>};		
	}
	case "bugzilla-check"
	{	
			$id=$queryString{ "id" };
				print qq{ <form action="aanswer.php?act=edit-ok" method="post" enctype="multipart/form-data" name="form">
					id:<br /><input type="text" size="10" maxlength="10" name="id" id="id" value="$id" /><br />
					ответ:<br /><textarea cols="35" rows="5" maxlength="100" name="otvet" id="otvet"></textarea><br />
					<input type="submit" name="send" id="send" value="Продолжить..." />
				</form>}
	}
}


print qq{
		<div id="footer">
			Template by <a style="color: #666;" href="http://creativecommons.org/">CC:by-sa</a> | &copy; xepec.ru | v. 0.2
		</div>
    </div>
  </div>
</div>
</body>
</html>};
